package com.gxh.controller.user;


import com.gxh.entity.Location;
import com.gxh.result.Result;
import com.gxh.service.LocationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userLocationController")
@RequestMapping("/user/location")
@Api(tags = "用户端设备地址相关接口")
@Slf4j
public class LocationController {

    @Autowired
    private LocationService locationService;

    /**
     * 查询所有地址
     */
    @GetMapping("/list")
    @ApiOperation("查询所有地址")
    @Cacheable(value = "locationCache",key = "'list'")
    public Result<List<Location>> list() {
        log.info("用户查询所有地址");
        List<Location> list = locationService.list();
        return Result.success(list);
    }

}
